<include file="Common:minheader" />
<!-- /. NAV SIDE  -->
<form class="layui-form" action="">
    <input type="hidden" name="id" value="{$info.id}">
	<div class="layui-form-item">
		<label class="layui-form-label">开始时间</label>
		<div class="layui-input-block">
			<input value="" type="text" name="begin_time" placeholder="请选择停卡开始时间" autocomplete="off" class="layui-input" id="addtime_fromdate">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">结束时间</label>
		<div class="layui-input-block">
			<input value="" type="text" name="end_time" placeholder="请选择停卡结束时间" autocomplete="off" class="layui-input" id="addtime_fromdate">
		</div>
	</div>
	<div class="layui-form-item" id="cardNums">
		<label class="layui-form-label">费用</label>
		<div class="layui-input-block">
		  <input value="" type="text" name="expense" required  lay-verify="required" placeholder="请输入费用" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">图片</label>
		<div class="layui-input-block">
			<div class="layui-upload">
				<button type="button" class="layui-btn" id="test2">上传图片</button>
				<div class="layui-upload-list" id="demo2" data-id="">
					<if condition="!empty($info['image_url'])">
						<div class="imgcss"><input type="hidden" name="image_url" id="smallimage1" value=""></div>
					</if>
				</div>
				<div id="demoText1"></div>
			</div>
		</div>
	</div>
	<div class="layui-form-item layui-form-text" style="z-index: 1;">
		<label class="layui-form-label">备注</label>
		<div class="layui-input-block">
			<textarea name="memo" placeholder="请输入备注" class="layui-textarea"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
		  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
  </div>
</form>
<script>
	//Demo
	layui.use('form', function(){
        var form = layui.form;
		layui.use('upload', function(){
			var $ = layui.jquery
					,upload = layui.upload;
			var uploadInst = upload.render({
				elem: '#test2'
				,url: "{:U('Common/uploadImage')}"
				,size:'0'
				,exts:'jpeg|gif|png|jpg'
				,multiple: false
				,method: 'POST'
				,before: function(obj){
					//预读本地文件示例，不支持ie8
					obj.preview(function(index, file, result){
						$('#demo2').html('<div class="imgcss"><input type="hidden" name="image_url" id="smallimage1"><img src="'+result+'" width="150"></div>'); //文件名
					});
				}
				,done: function(res){
					//如果上传失败
					if(res.code==0){
						return layer.msg(res.value);
					}else{
						$('#smallimage1').val(res.value);
					}
				}
				,error: function(){
					//演示失败状态，并实现重传
					var demoText = $('#demoText1');
					demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
					demoText.find('.demo-reload').on('click', function(){
						uploadInst.upload();
					});
				}
			});
		});
        form.on('submit(formDemo)', function(data){
        	var cont = data.field;
        	$.ajax({
        		url:"{:U('Users/stopUserCard')}",
        		type:'post',
        		dataType:'json',
        		data:cont,
        		success:function(data){
        			if(data.code==0){
        				layer.alert(data.message);
        			}else{
        				layer.alert(data.message, function(index){
        					//do something
        					window.parent.location.reload();
        					var index = parent.layer.getFrameIndex(window.name); 
        					parent.layer.close(index);
        				});
        			}
        		}
        	});
        	//layer.msg(JSON.stringify(data.field));
        	return false;
        });
	});
</script>
<!-- /. PAGE INNER  -->
<include file="Common:footer" />